#include "../Delta-Ray/log.h"

Log::Log(){
    Log_File.open("Delta-Ray.log",ios::out|ios::trunc);
    if(Log_File.good() == true){
        cout<<"LOG FILE CLEAR!"<<endl;
        Log_File.flush();
        Log_File.close();
    }
    else {
        cout<<"ERROR: Delta-Ray.log cant be open!!"<<endl;
        Log_File.close();
    }
    Log_File.open("Delta-Ray.log",ios::out|ios::app);
    if(Log_File.good() == true){
        time(&dat);
        data=ctime(&dat);
        data.erase(data.size()-1,1);
        cout<<"LOG: "<<"=="<<data<<"=="<<endl;
        Log_File<<"=="<<data<<"=="<<endl;
        Log_File<<"=="<<ENG_VER<<"=="<<endl;
        Log_File<<"=="<<"MINUTE ALFA"<<"=="<<endl;
        Log_File.flush();
        Log_File.close();
    }
    else {
        cout<<"ERROR: Delta-Ray.log cant be open!!"<<endl;
        Log_File.close();
    }
}

void Log::LogText(string a_save){
    Log_File.open("Delta-Ray.log",ios::out|ios::app);
    if(Log_File.good() == true){
        cout<<"LOG: "<<a_save<<endl;
        Log_File<<a_save<<endl;
        Log_File.flush();
        Log_File.close();
    }
    else {
        cout<<"ERROR: Delta-Ray.log cant be open!!"<<endl;
        Log_File.close();
    }
}
